var UserPermission = require('../../models/UserPermission');
var _ = require('underscore');

var root = require('../../config/user_permission');

//保存目录
save(root);

function save(permission) {

    UserPermission.create(permission).then(function (doc) {
        console.log(doc);
    });

    if (permission.nodes) {
        _.each(permission.nodes, function (obj, key) {
            save(obj);
        });
    }
}